package main

import (
	"math"
	"strconv"
	"strings"
)

func get_left(s string) int {
	ans := strings.Builder{}
	for i := 0; i < len(s); i++ {
		ch := rune(s[i])
		if ch == '/' {
			break
		} else {
			ans.WriteRune(ch)
		}
	}
	val, _ := strconv.Atoi(ans.String())
	return val
}

func reverseBytes(s []byte) []byte {
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
	return s
}

func get_right(s string) int {
	ans := strings.Builder{}
	flag := false
	for i := 0; i < len(s); i++ {
		ch := rune(s[i])
		if ch == '/' {
			flag = true
			continue
		}
		if flag {
			ans.WriteRune(ch)
		}
	}
	val, _ := strconv.Atoi(ans.String())
	return val
}

func gcd(a int, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		temp := a % b
		a = b
		b = temp
	}
	return a
}

type ListNode struct {
	Val  int
	Next *ListNode
}

func ReverseList(head *ListNode) *ListNode {
	// write code here
	var pre *ListNode = nil
	var cur = head
	for cur != nil {
		tmp := cur.Next
		cur.Next = pre
		pre = cur
		cur = tmp
	}
	return pre
}

func max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}
func maxSum(nums []int) int {
	map1 := map[int]int{}
	mx := math.MinInt32
	s := 0
	for _, x := range nums {
		if x < 0 {
			mx = max(mx, x)
		} else {
			_, ok := map1[x]
			if !ok {
				map1[x] = 1
				s += x
			}
		}
	}
	if len(map1) == 0 {
		return mx
	}
	return s
}
func main() {

}
